package ae.pcfc.etks.online.itworx.ehs.web;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import oracle.jdbc.OracleCallableStatement;
import oracle.jdbc.OracleTypes;

public class testResult  {
  public testResult() {
    try {
      DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
      Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@jmiddb01.dubaiworld.ae:1669:DNCPRD", "TSC_RW", "TSC_RW");
      CallableStatement stmt = conn.prepareCall("BEGIN P_GET_LICENCE_ACTIVITY('JAFZA','987678','C-E-773076',null,null, ?); END;");
      //stmt.setString(1, "JAFZA");
      //stmt.setString(2, "987678");
      //stmt.setString(3, null);
      //stmt.setString(4, null);
      //stmt.setString(5, null);
      stmt.registerOutParameter(1, OracleTypes.CURSOR); //REF CURSOR
      stmt.execute();
      ResultSet rs = ((OracleCallableStatement)stmt).getCursor(1);
      while (rs.next()) {
        System.out.println(rs.getString(1));//getString("ename") + ":" + rs.getString("empno") + ":" + rs.getString("deptno")); 
      }
      rs.close();
      rs = null;
      stmt.close();
      stmt = null;
      conn.close();
      conn = null;
    }
    catch (SQLException e) {
      System.out.println(e.getLocalizedMessage());
    }
  }

  public static void main (String[] args) {
    new testResult();
  }
}